﻿using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace Quickuse.Logging
{
    /// <summary>
    /// LoggingConfiguration
    /// </summary>
    internal class LoggingConfiguration : ILoggingConfiguration
    {
        private IConfiguration _configuration;

        public LoggingConfiguration()
        {
            //读取配置文件
            var filepath = Path.Combine(Directory.GetCurrentDirectory(), PublicConst.ConfigFileName);

            if (File.Exists(filepath))
            {
                var builder = new ConfigurationBuilder()
                            .SetBasePath(Directory.GetCurrentDirectory())
                            .AddJsonFile(PublicConst.ConfigFileName, optional: false, reloadOnChange: true);

                _configuration = builder.Build() as IConfiguration;
            }
        }

        public IConfiguration Configuration => _configuration;
    }
}
